package com.cyufeng.blog.service.mapper;

import com.cyufeng.blog.dto.HotArticleDto;
import com.cyufeng.blog.entity.HotArticle;

import java.util.ArrayList;
import java.util.List;

/**
 * 热门文章
 *
 * @author Cyufeng
 * Data:2019.01.12
 */
public class HotArticleMapper {
    public HotArticleDto entityTodto(HotArticle hotArticle) {
        HotArticleDto hotArticleDto = new HotArticleDto();
        hotArticleDto.setId(hotArticle.getId());
        hotArticleDto.setArticleId(hotArticle.getArticleId());
        hotArticleDto.setArticleTitle(hotArticle.getArticleTitle());
        hotArticleDto.setIsEnable(hotArticle.getIsEnable());
        hotArticleDto.setDr(hotArticle.getDr());
        hotArticleDto.setMadeTime(hotArticle.getMadeTime());
        hotArticleDto.setDelTime(hotArticle.getDelTime());
        hotArticleDto.setIsTool(hotArticle.getIsTool());
        return hotArticleDto;
    }

    public HotArticle dtoToentity(HotArticleDto hotArticleDto) {
        HotArticle hotArticle = new HotArticle();

        hotArticle.setId(hotArticleDto.getId());
        hotArticle.setArticleId(hotArticleDto.getArticleId());
        hotArticle.setArticleTitle(hotArticleDto.getArticleTitle());
        hotArticle.setDr(hotArticleDto.getDr());
        hotArticle.setIsEnable(hotArticleDto.getIsEnable());
        hotArticle.setMadeTime(hotArticleDto.getMadeTime());
        hotArticle.setDelTime(hotArticleDto.getDelTime());
        hotArticle.setIsTool(hotArticleDto.getIsTool());

        return hotArticle;
    }

    //list集合
    public List<HotArticleDto> entityTodto(List<HotArticle> emailList) {
        List<HotArticleDto> emailDtoList = new ArrayList<>();
        for (int i = 0; i < emailList.size(); i++) {
            HotArticle hotArticle = emailList.get(i);
            HotArticleDto hotArticleDto = new HotArticleDto();

            hotArticleDto.setId(hotArticle.getId());
            hotArticleDto.setArticleId(hotArticle.getArticleId());
            hotArticleDto.setArticleTitle(hotArticle.getArticleTitle());
            hotArticleDto.setIsEnable(hotArticle.getIsEnable());
            hotArticleDto.setDr(hotArticle.getDr());
            hotArticleDto.setMadeTime(hotArticle.getMadeTime());
            hotArticleDto.setDelTime(hotArticle.getDelTime());
            hotArticleDto.setIsTool(hotArticle.getIsTool());

            emailDtoList.add(hotArticleDto);
        }

        return emailDtoList;
    }

    public List<HotArticle> dtoToentity(List<HotArticleDto> emailDtoList) {
        List<HotArticle> emailList = new ArrayList<>();
        for (int i = 0; i < emailList.size(); i++) {
            HotArticle hotArticle = new HotArticle();
            HotArticleDto hotArticleDto = emailDtoList.get(i);

            hotArticle.setId(hotArticleDto.getId());
            hotArticle.setArticleId(hotArticleDto.getArticleId());
            hotArticle.setArticleTitle(hotArticleDto.getArticleTitle());
            hotArticle.setDr(hotArticleDto.getDr());
            hotArticle.setIsEnable(hotArticleDto.getIsEnable());
            hotArticle.setMadeTime(hotArticleDto.getMadeTime());
            hotArticle.setDelTime(hotArticleDto.getDelTime());
            hotArticle.setIsTool(hotArticleDto.getIsTool());

            emailList.add(hotArticle);
        }
        return emailList;
    }
}
